var app = getApp();

Page({
    data: {
        index: 0,
        base: !1
    },
    onLoad: function(a) {
         var e = this, u = wx.getStorageSync("users").id;
        app.util.request({
            url: "entry/wxapp/bindhx",
            cachetime: "0",
            data: {
                id: a.store_id
            },
            success: function(t) {   
                e.setData({
                    hxm:t.data

                })
            }
        });
        this.setData({
           
            store_id: a.store_id
        });
        app.pageOnLoad(this), app.setNavigationBarColor(this), this.reload();
    },
    hxdd: function() {
        wx.setStorageSync("hxsjid", this.data.store_id), wx.scanCode({
            success: function(e) {
                console.log(e);
                var t = "../" + e.path.substring(14);
                wx.navigateTo({
                    url: t
                });
            },
            fail: function(e) {
                console.log("扫码fail"), wx.removeStorageSync("hxsjid");
            }
        });
    },
    hxyhq: function() {
        wx.setStorageSync("hxsjid", this.data.store_id), wx.scanCode({
            success: function(e) {
                console.log(e);
                var t = "/" + e.path;
                wx.navigateTo({
                    url: t
                });
            },
            fail: function(e) {
                console.log("扫码fail"), wx.removeStorageSync("hxsjid");
            }
        });
    },
    hxqgdd: function() {
        var n = this.data.store_id;
        wx.scanCode({
            success: function(e) {
                console.log(e);
                var t = "/" + e.path;
                wx.navigateTo({
                    url: t + "&storeid=" + n
                });
            },
            fail: function(e) {
                console.log("扫码fail");
            }
        });
    },
    reload: function(a) {
        var t = this, e = wx.getStorageSync("System");
        console.log(e);
        var n = wx.getStorageSync("url");
        t.setData({
            url: n,
            pt_name: e.pt_name,
            System: wx.getStorageSync("System")
        }), app.util.request({
            url: "entry/wxapp/type",
            cachetime: "0",
            success: function(a) {
                console.log(a);
                var e = a.data;
                t.setData({
                    nav: e
                });
            }
        });
    },
    settled: function(a) {
        wx.navigateTo({
            url: "../../settled/settled",
            success: function(a) {},
            fail: function(a) {},
            complete: function(a) {}
        });
    },
    formSubmit: function(e) {
        var a = this;
        var t = e.detail.value.hx_code;
        var w = "";
        if ("" == t) w = "核销码不能为空"; 
        if ("" != w) wx.showModal({
            title: "提示",
            content: w,
            showCancel: !0,
            cancelText: "取消",
            confirmText: "确定",
            success: function(e) {},
            fail: function(e) {},
            complete: function(e) {}
        }); else {
          app.util.request({
                url: "entry/wxapp/hxinputcode",
                cachetime: "0",
                data: {
                    store_id: a.data.store_id,
                    hx_code:t
                },
                success: function(e) {
                    console.log(e), 1 == e.data && (wx.showToast({
                        title: "核销成功",
                        icon: "",
                        image: "",
                        duration: 2e3,
                        mask: !0,
                        success: function(e) {},
                        fail: function(e) {},
                        complete: function(e) {}
                    }),setTimeout(function() {
                        wx.navigateBack({
                            delta: 1
                        });
                    }, 2e3)),!1== e.data && (wx.showModal({
                                                            title: "请输入正确核销码",
                                                            content: w,
                                                            showCancel: !0,
                                                            cancelText: "取消",
                                                            confirmText: "确定",
                                                            success: function(e) {},
                                                            fail: function(e) {},
                                                            complete: function(e) {}
                                                        }),
                        setTimeout(function() {
                        wx.navigateBack({
                            delta: 1
                        });
                    }, 1e3));
                }
            });
        }
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});